package de.szut.sudoku.gui.sudokufield;

import java.awt.Color;
import java.awt.event.KeyAdapter;
import java.awt.event.MouseAdapter;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.border.Border;

/**
 * Inheritance class for notebuttons and sudokubuttons
 * 
 * @author Marc Huisinga
 * 
 */
@SuppressWarnings("serial")
public class SudokuFieldLabel extends JLabel {
	public final static Color DEFAULTCOLOR = Color.WHITE;
	public final static Color SWITCHCOLOR = Color.CYAN;
	public final static Color DEFAULTTEXTCOLOR = Color.BLACK;
	public final static Color PRESETTEXTCOLOR = Color.BLUE;

	/**
	 * Sets the text to an empty value, should the value be 0
	 * 
	 * @param text
	 */
	public void setSudokuText(String text) {
		if (text.equals("0")) {
			setText("");
		} else {
			setText(text);
		}
	}

	/**
	 * generates the label upon instantiating
	 * 
	 * @param xPosition
	 * @param yPosition
	 * @param keyListener
	 * @param clickListener
	 */
	public SudokuFieldLabel(int xPosition, int yPosition,
			KeyAdapter keyListener, MouseAdapter clickListener) {
		Color defaultBGColor = DEFAULTCOLOR;
		addKeyListener(keyListener);
		addMouseListener(clickListener);
		setOpaque(true);
		setHorizontalAlignment(SwingConstants.CENTER);
		setForeground(Color.BLACK);
		setBackground(defaultBGColor);
		setBounds(xPosition, yPosition, 0, 0);
		Border blackLine = BorderFactory.createLineBorder(Color.black);
		setBorder(blackLine);
	}
}
